from func_define import *

'''方案三：动态分配养鱼'''        #2792789.9969272073
ans = 0
ans_num_fish_2 = 0
for i in range(1,361):
    ans += math.pow(1000,i/360)
# 假设每天投入fish_num_everyday只鱼，那么到360天（已经有fish_num_everyday条鱼可以出去）时，就已经可以收钱了
fish_num_everyday = int(10000*500//ans)     # 95

everyday_add = fish_num_everyday*1/500
weight_num = [everyday_add]
for i in range(1,361):
    # 第i天的重量
    temp = everyday_add * pow(1000,i/360)
    weight_num.append(weight_num[-1] + temp)
print(weight_num[-1])

# 假设第k天时候投入5000尾，正好在第365x3天时候，收获5000尾

k = 365*3 - 360 + 1 #到该天时，不再增加固定的鱼苗，转而投放5000尾

for i in range(361,k-1):
    # 第i天的重量
    ans_num_fish_2 += fish_num_everyday
    weight_num.append(weight_num[-1])
# an = an-1 (q+1) = 1/500*(1000^(n/360))
# q = 1000^(1/360) - 1
add_num = weight_num[-1]

for i in range(k,365*3+1):
    add_num = (add_num-2*fish_num_everyday) * pow(1000,1/360)
    ans_num_fish_2 += fish_num_everyday
    add_num2 = 5000*1/500*pow(1000,(i-k)/360)
    weight_num.append(add_num+add_num2)
ans_num_fish_2+=5000

# 最后一天必须要卖完
get_plot_show(range(len(weight_num)),weight_num,ylabel=r'当天池塘容纳重量/kg',label_name=None,
                  title=r'模型3池塘容纳重量随时间的变化')
print(weight_num[-1])
weight_num_np = np.array(weight_num)
cost_all = food_cost_day(weight_num_np)
print("动态规划的收益:",ans_num_fish_2*20*2)
print("动态规划的消耗:",sum(cost_all))
print("动态规划的利润:",ans_num_fish_2*20*2-sum(cost_all))
